package com.suray.wcs.service.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.suray.basic.wcs.utils.IBaseEnum;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description:接驳模式
 * @author: chenhw
 * @date:2022年8月15日 下午5:50:08
 */
public enum ConnectModel implements IBaseEnum<Serializable> {
    NOT_CONNECT(0, "不接驳"),
    NEED_CONNECT(1,"接驳"),
//    IN_CONNECT(1, "入库接驳"),
//    OUT_CONNECT(2, "出库接驳"),
//    ALL_CONNECT(3, "全接驳"),
    ;


    public static Map<Integer, String> typeMap = new HashMap<Integer, String>();

    static {
        ConnectModel[] types = ConnectModel.values();
        for (ConnectModel type : types) {
            typeMap.put(type.num, type.toString());
        }
    }

    @EnumValue
    private final Integer num;
    @JsonValue
    private final String desc;

    ConnectModel(int state, String descp) {
        this.num = state;
        this.desc = descp;
    }

    @Override
    public String toString() {
        return desc;
    }

    @Override
    public Integer getValue() {
        return num;
    }

    /**
     * @param num
     * @return PortType
     */
    public static ConnectModel parsePortType(int num) {
        ConnectModel[] portTypes = ConnectModel.values();
        for (ConnectModel portType : portTypes) {
            if (portType.num == num) {
                return portType;
            }
        }
        throw new IllegalArgumentException("库口类型参数异常");
    }

    @Override
    public String getDescription() {
        return desc;
    }

    @Override
    public Integer getVal() {
        return num;
    }
}
